/**
	Edit account dialogue.
 */
Ext.define('WEB.view.account.Edit', {
	extend: 'Ext.window.Window',
	alias : 'widget.accountedit',

	title : 'Edit Account',
	layout: 'fit',
	autoShow: true,
	resizable: false,
	modal: true,
	width: 350,
	
	initComponent: function() {
		this.items = [
			{
				xtype: 'form',
				bodyPadding: 10,
				border: false,
				items: [{
						xtype: 'textfield',
						tabIndex: 10,
						anchor: '100%',
						name : 'name',
						fieldLabel: 'Name',
						allowBlank: false,
					}, {
						xtype: 'fieldcontainer',
						anchor: '100%',
						fieldLabel: 'Currency',
						layout: 'hbox',
						defaults: {
							margin: '0 1'
						},
						fieldDefaults: {
							msgTarger: 'under',
							labelAlign: 'top'
						},
						items: [{
							xtype: 'combo',
							tabIndex: 20,
							anchor: '100%',
							name : 'currency_code',
							//fieldLabel: 'Currency',
							allowBlank: false,
							forceSelection: true,
							store: 'Currencies',
							queryMode: 'local',
							displayField: 'codename',
							valueField: 'code',
							emptyText: 'Select a currency',
							flex: 4
						}, {
							xtype: 'button',
							icon: 'res/img/icon-add16x16.gif',
							text: '',
							minWidth: 16,
							tooltip: 'Create new currency',
							action: 'newcurrency'
						}]
					}, {
						xtype: 'numberfield',
						tabIndex: 30,
						anchor: '100%',
						name : 'initbalance',
						fieldLabel: 'Balance',
						allowBlank: false,
						allowDecimals: true
					}, {
						xtype: 'textareafield',
						tabIndex: 35,
						grow: true,
						anchor: '100%',
						name : 'description',
						fieldLabel: 'Description'
					}, {
						xtype: 'checkboxfield',
						tabIndex: 37,
						//anchor: '100%',
						name : 'isclosed',
						inputValue: 'true',
						uncheckedValue: 'false',
						fieldLabel: 'Account is closed'
				}]
			}
		];

		this.buttons = [
			{
				text: 'Save',
				tabIndex: 40,
				action: 'save'
			},
			{
				text: 'Cancel',
				tabIndex: 50,
				scope: this,
				handler: this.close
			}
		];

		this.on('show', function(wnd) {
			wnd.down("textfield[name=name]").focus(true, 200);
		});
		
		this.callParent(arguments);
	}
});